<template>
	<view>
		<view>
			<view>
				<!-- <navigator url="company/info" open-type="navigate"> -->

				<view class="list-item" hover-class="list-item_active">
					<view class="div2-line"></view>
					<view class='item' @click="Mylogin">
						<image class='item2-image' src='@/static/img/my/company.png' mode='aspectFill' lazy-load='true'></image>
						<text class="item2-text">{{name==""?"点我登录(๑•̀ㅂ•́)و✧":name}}</text>
						<!-- <button class="item2-text" hover-class='none' plain open-type="getUserInfo" @getuserinfo="bindGetUserInfo">登录</button> -->
					</view>
					<view class="div2-line"></view>
				</view>
				<!-- </navigator> -->
			</view>
			<view>
				<navigator url="/pages/my/company/info" open-type="navigate">
					<view class="list-item" hover-class="list-item_active">
						<view class='item'>
							<image class='item-image' src='@/static/img/my/info.png' mode='aspectFill' lazy-load='true'></image>
							<text class="item-text">我的信息</text>
							<view class='item-array'>
								<image src="@/static/img/my/info_68_68.jpg" class="img" mode="aspectFill" lazy-load="true"></image>
							</view>
						</view>
						<view class="div-line"></view>
					</view>
				</navigator>
			</view>
			<view>
				<navigator url="/pages/my/notice" open-type="navigate">
					<view class="list-item" hover-class="list-item_active">
						<view class='item'>
							<image class='item-image' src='@/static/img/my/msg.png' mode='aspectFill' lazy-load='true'></image>
							<text class="item-text">我的通知</text>
							<view class='item-array'>
								<image src="@/static/img/my/info_68_68.jpg" class="img" mode="aspectFill" lazy-load="true"></image>
							</view>
						</view>
						<view class="div-line"></view>
					</view>
				</navigator>
			</view>
			<view>
				<navigator url="/pages/my/help" open-type="navigate">
					<view class="list-item" hover-class="list-item_active">
						<view class='item'>
							<image class='item-image' src='@/static/img/my/help.png' mode='aspectFill' lazy-load='true'></image>
							<text class="item-text">帮助中心</text>
							<view class='item-array'>
								<image src="@/static/img/my/info_68_68.jpg" class="img" mode="aspectFill" lazy-load="true"></image>
							</view>
						</view>
						<view class="div-line"></view>
					</view>
				</navigator>
			</view>
			<view>
				<navigator url="/pages/my/about">
					<view class="list-item" hover-class="list-item_active">
						<view class='item'>
							<image class='item-image' src='@/static/img/my/about.png' mode='aspectFill' lazy-load='true'></image>
							<text class="item-text">关于我们</text>
							<view class='item-array'>
								<image src="@/static/img/my/info_68_68.jpg" class="img" mode="aspectFill" lazy-load="true"></image>
							</view>
						</view>
						<view class="div-line"></view>
					</view>
				</navigator>
			</view>
			<!-- <view v-if="role=='teacher'||role=='enterprise'"> -->
			<view >
				<view class="list-item" hover-class="list-item_active" @click="goDataAnalysls()">
					<view class='item'>
						<image class='item-image' src='@/static/img/my/lookdata.png' mode='aspectFill' lazy-load='true'></image>
						<text class="item-text">数据展示</text>
						<view class='item-array'>
							<image src="@/static/img/my/info_68_68.jpg" class="img" mode="aspectFill" lazy-load="true"></image>
						</view>
					</view>
					<view class="div-line"></view>
				</view>
			</view>
			<view>
				<view class="list-item" hover-class="list-item_active">
					<view class='item' @click="clearCache">
						<image class='item-image' src='@/static/img/my/about.png' mode='aspectFill' lazy-load='true'></image>
						<text class="item-text">注销</text>
						<view class='item-array'>
							<image src="@/static/img/my/info_68_68.jpg" class="img" mode="aspectFill" lazy-load="true"></image>
						</view>
					</view>
					<view class="div-line"></view>
				</view>
			</view>
			
		</view>
		<uni-popup ref="popupLogin" type="dialog">
			<wu-popup-login @refdata="loadData1" type="success" :content="message" :before-close="true" @confirm="dialogConfirm"
			 @close="dialogClose"></wu-popup-login>
		</uni-popup>
		
		<uni-popup ref="popupConClear" type="dialog">
			<!-- title="通知1" -->
			<uni-popup-dialog type="success" :content="message" :before-close="true" @confirm="ClearConfirm" @close="ClearClose">
			</uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import {
		// getTest,
		getStudentInfo,
		getMsgsReceive
	} from '@/api/my/service.js';

	import WuPopupLogin from '@/components/uni-popup/wu-popup-login.vue'
	import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
	
	export default {
		components: {
			WuPopupLogin,
			uniPopupMessage,
			uniPopupDialog
		},
		data() {
			return {
				// Stuid: 0,
				studentInfo: null,
				navData: "",
				role: "s",
				name: "",
				type: 0,
				Infomation: null,
				message: ""
			}

		},
		created() {
			// const Stuid = uni.getStorageSync("Stuid");
			// this.Stuid = Stuid;
			this.getMyData();

		},
		onLoad() {

			this.role = uni.getStorageSync("role");
			this.loadData();


		},
		methods: {
			ClearConfirm(done) {
				console.log('点击确认清除缓存');
				uni.clearStorageSync();
				this.name='';
				done()
			},
			ClearClose(done) {
				console.log('点击取消清除缓存');
				// 需要执行 done 才能关闭对话框
				done()
			},
			
			clearCache() {
				this.message="是否退出登录？"
				this.$refs.popupConClear.open();
			},
			dialogConfirm(done) {
				console.log('点击确认');

				done()
			},
			dialogClose(done) {
				console.log('点击取消');
				uni.showToast({
					title: "您点击取消!!",
					duration: 2000,
					icon: "none"
				})
				done()
			},

			loadData1() {
				console.log("-----");
				this.name = uni.getStorageSync("Infomation").name;
			},
			Mylogin() {
				this.Infomation = uni.getStorageSync("Infomation");
				// console.log(this.Infomation, "---------")
				if (this.Infomation == '') {
					console.log("---------Mylogin");
					// this.flag = true
					this.message = "想要获取权限进行登录!!";
					this.$refs.popupLogin.open();
					console.log("-----------Aaaaa----------")
				}
			},
			topath() {
				uni.navigateTo({
					url: '../index/index',
					success: () => {
						console.log("123");
					}
				});
			},
			uploadImage() {
				uni.chooseImage({
					count: 1, //默认9
					sourceType: ['album'], //从相册选择
					success: function(res) {
						console.log(JSON.stringify(res.tempFilePaths));
					}
				});
			},

			//页面跳转
			goDataAnalysls() {
				uni.navigateTo({
					url: '/pages/my/dataAnalysis/dataAnalysis'
				})
			},
			//获取数据
			getMyData() {
				const data = uni.getStorageSync("Infomation");
				if (this.role == 'teacher') {
					this.name = data.name;
					this.type = 0;
				} else if (this.role == 'enterprise') {
					this.name = data.name;
					this.type = 1;
				} else {
					this.name = data.name;
					this.type = 2;
				}
			},
			loadData() {
				const token = uni.getStorageSync("token");
				console.log(token, this.type);
				getMsgsReceive(token, this.type).then(res => {
					this.notice = res.data;
					console.log(this.notice);
					uni.setStorage({
						key: "notice",
						data: res.data,
					});
				}).catch(res => {
					console.log(res);
				});
			},
		}
	}
</script>

<style>
	.list-wrapper {
		width: 100%;
	}

	.div-line {
		background: #E0E3DA;
		width: 100%;
		height: 3rpx;
	}


	.list-item {
		width: 100%;
		height: 120rpx;
	}

	.list-item_active {
		background-color: #E0E3DA;
	}

	.item {
		display: flex;
		flex-direction: row;
		align-items: center;
		height: 120rpx;
	}

	.item-text {
		position: fixed;
		left: 100rpx;
		font-size: 38rpx;
	}

	.item-array {
		position: absolute;
		right: 50rpx;
	}

	.item-image {
		position: fixed;
		left: 50rpx;
		width: 40rpx;
		height: 40rpx;
	}

	.item2 {
		display: flex;
		flex-direction: row;
		align-items: center;
		height: 260rpx;
	}

	.item2-text {
		position: fixed;
		left: 120rpx;
		font-size: 34rpx;
		background: transparent;
		/*按钮背景透明*/
		border-width: 0px;
		/*边框透明*/
		outline: none;
		/*点击后没边框*/
	}


	button::after {
		border: none;
	}

	.item2-image {
		position: fixed;
		left: 50rpx;
		width: 47rpx;
		height: 47rpx;
	}

	.div2-line {
		background: #F5F5F5;
		width: 100%;
		height: 13rpx;
	}

	.img {
		width: 20rpx;
		height: 20rpx;
	}
</style>
